-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2way sync: Better view handling #13494
base: master
Are you sure you want to change the base?
Conversation
tobiasKaminsky
commented
Aug 30, 2024
- empty state
- Tests written, or not not needed
- empty state Signed-off-by: tobiasKaminsky <[email protected]>
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/13494.apk |
|
||
setupToolbar() | ||
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_synced_folders)) | ||
if (supportActionBar != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need null check, you can use this. supportActionBar?.setDisplayHomeAsUpEnabled(true)
lateinit var binding: InternalTwoWaySyncLayoutBinding | ||
|
||
@Inject | ||
lateinit var viewThemeUtils: ViewThemeUtils | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
binding = InternalTwoWaySyncLayoutBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
binding.list.apply { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can omit the binding prefix for emptyList.
Instead of apply, use run when there’s no need to return a modified instance at the end of the block. Use apply only when assigning to a variable.
binding.list.run {
setEmptyView(binding.emptyList.emptyListView)
binding.emptyList.run {
emptyListViewHeadline.run {
visibility = View.VISIBLE
setText(R.string.internal_two_way_sync_list_empty_headline)
}
emptyListViewText.run {
visibility = View.VISIBLE
setText(R.string.internal_two_way_sync_text)
}
emptyListIcon.run {
visibility = View.VISIBLE
setImageDrawable(
viewThemeUtils.platform.tintDrawable(
context,
R.drawable.ic_sync,
ColorRole.PRIMARY
)
)
}
}
adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), context).apply {
notifyDataSetChanged()
}
layoutManager = LinearLayoutManager(context)
}
Alternatively you can omit second binding as well.
binding.run {
list.run {
setEmptyView(binding.emptyList.emptyListView)
emptyList.run {
emptyListViewHeadline.run {
visibility = View.VISIBLE
setText(R.string.internal_two_way_sync_list_empty_headline)
}
emptyListViewText.run {
visibility = View.VISIBLE
setText(R.string.internal_two_way_sync_text)
}
emptyListIcon.run {
visibility = View.VISIBLE
setImageDrawable(
viewThemeUtils.platform.tintDrawable(
context,
R.drawable.ic_sync,
ColorRole.PRIMARY
)
)
}
}
adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), context).apply {
notifyDataSetChanged()
}
layoutManager = LinearLayoutManager(context)
}
}
lateinit var binding: InternalTwoWaySyncLayoutBinding | ||
|
||
@Inject | ||
lateinit var viewThemeUtils: ViewThemeUtils | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add @SuppressLint("NotifyDataSetChanged") since code updates InternalTwoWaySyncAdapter items in onCreate